<%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" %>


<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim strFile As String = FileUpload1.FileName.ToString()
        Dim StrLoc As String = Server.MapPath("~/Documents/" & strFile)
        FileUpload1.PostedFile.SaveAs(StrLoc)
        SqlDataSource1.InsertParameters.Add("URL", strFile)
        SqlDataSource1.InsertParameters.Add("Title", TitleTXT.Text.ToString)
        SqlDataSource1.Insert()
        Response.Redirect("~/" & CStr(Request.QueryString("ReturnURL")), True)
    End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="body">
    <div class="fullwidth">
        <h2>Add Download</h2>    
        <p>
            <strong>Title</strong>:
            <asp:TextBox ID="TitleTXT" runat="server" Width="379px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TitleTXT"
                ErrorMessage="Please Enter a Title"></asp:RequiredFieldValidator></p>
        <p>
            <strong>File</strong>:
            <asp:FileUpload ID="FileUpload1" runat="server" Width="392px" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="FileUpload1"
                ErrorMessage="Please Select a File."></asp:RequiredFieldValidator></p>
        <p>
            <Club:RolloverButton ID="Button1" runat="server" Text="Upload" OnClick="Button1_Click" />&nbsp;</p>
        <p>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>"
                InsertCommand="INSERT INTO [Downloads] ([URL], [Title]) VALUES (@URL, @Title)">
            </asp:SqlDataSource>
            </p>
    </div>
</div>
</asp:Content>

